package org.dromara.common.core.utils.concurrent;

import java.util.concurrent.Callable;

public class ExecRunnable<T> implements Runnable {

    private final BasicFuture<T> future;
    private final Callable<T> callable;
    private String name;

    public ExecRunnable(final String name,
                        final Callable<T> callable,
                        final BasicFuture<T> future) {
        super();
        this.name = name;
        this.future = future;
        this.callable = callable;
    }

    @Override
    public void run() {
        try {
            final T result = callable.call();
            this.future.completed(result);
        } catch (final Exception ex) {
            this.future.failed(ex);
        }
    }

}
